Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
is-builtin-module
Advanced tools
The is-builtin-module npm package is used to check if a given module name corresponds to a Node.js built-in module. This can be useful when developing tools that need to differentiate between built-in modules and third-party modules, such as bundlers, linters, or dependency analysis tools.
Check if a module is a built-in module
This feature allows you to check if a given string corresponds to a Node.js built-in module. In the code sample, 'fs' is recognized as a built-in module, while 'express' is not.
const isBuiltinModule = require('is-builtin-module');
console.log(isBuiltinModule('fs')); // true
console.log(isBuiltinModule('express')); // false
The 'builtin-modules' package provides a list of the built-in modules of Node.js. It is similar to 'is-builtin-module' but instead of checking if a module is built-in, it provides the full list of built-in modules. You can use this list to check for built-in modules manually.
The 'resolve' package is a module resolution algorithm for Node.js, similar to the one used by 'require'. It can be used to check if a module is resolvable and, by extension, to infer if it is a built-in module. However, it is more general-purpose and not specifically designed for checking built-in modules.
Check if a string matches the name of a Node.js builtin module
$ npm install is-builtin-module
const isBuiltinModule = require('is-builtin-module');
isBuiltinModule('fs');
//=> true
isBuiltinModule('fs/promises');
//=> true
isBuiltinModule('node:fs/promises');
//=> true
isBuiltinModule('unicorn');
//=> false
FAQs
Check if a string matches the name of a Node.js builtin module
The npm package is-builtin-module receives a total of 5,347,974 weekly downloads. As such, is-builtin-module popularity was classified as popular.
We found that is-builtin-module demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.